package com.sky.controller.user;

import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersSubmitDTO;
import com.sky.result.Result;
import com.sky.service.OrdersService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: zhaoss
 * @Date: 2023/5/6 - 05 - 06 - 17:17
 * @Description: com.sky.controller.user
 * @version: 1.0
 */
@RestController("userOrdersController")
@RequestMapping("/user/order")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;
    /**
     * 下单
     * @return
     */
    @PostMapping("/submit")
    @ApiOperation("下单")
    public Result submit(@RequestBody OrdersSubmitDTO dto){
        return ordersService.submit(dto);
    }

    /**
     * 查询历史订单
     * @param dto
     * @return
     */
    @GetMapping("historyOrders")
    @ApiOperation("查询历史订单")
    public Result pageHistoryOrders(OrdersPageQueryDTO dto){
        return ordersService.pageHistoryOrders(dto);
    }


    /**
     * 订单详情
     * @return
     */
    @GetMapping("/orderDetail/{id}")
    @ApiOperation("订单详情")
    public Result getDetails(@PathVariable Long id){
        return ordersService.getDetails(id);
    }

    /**
     * 取消订单
     * @param id
     * @return
     */
    @PutMapping("/cancel/{id}")
    @ApiOperation("取消订单")
    public Result putOrder(@PathVariable Long id){
        return ordersService.putOrder(id);
    }

    /**
     * 再来一单
     * @param id
     * @return
     */
    @PostMapping("/repetition/{id}")
    @ApiOperation("再来一单")
    public Result recurOrder(@PathVariable Long id){
        return ordersService.recurOrder(id);
    }

    /**
     * 用户催单
     *
     * @param id
     * @return
     */
    @GetMapping("/reminder/{id}")
    @ApiOperation("用户催单")
    public Result reminder(@PathVariable("id") Long id) {
        ordersService.reminder(id);
        return Result.success();
    }
}
